//
//  LCGlobalVideoDetailViewController.m
//  lechuang
//
//  Created by Mr_hi on 2024/8/30.
//  Copyright © 2024 Mooyi. All rights reserved.
//

#import "LCGlobalVideoDetailViewController.h"
#import "LCGlobalVideoModel.h"
#import "TZImageManager.h"
@interface LCGlobalVideoDetailViewController ()

@property (weak, nonatomic) IBOutlet UIImageView *filmthumbView;

@property (weak, nonatomic) IBOutlet UILabel *filmtitleLb;

@property (weak, nonatomic) IBOutlet UILabel *sourcecharLb;

@property (weak, nonatomic) IBOutlet UILabel *shareNumLb;

@property (weak, nonatomic) IBOutlet UILabel *prodateLb;

@property (weak, nonatomic) IBOutlet UIView *qrcodeBg;

@property (weak, nonatomic) IBOutlet UIImageView *qrcodeView;

@property (weak, nonatomic) IBOutlet UILabel *filmdescLb;

@end

@implementation LCGlobalVideoDetailViewController

- (IBAction)backAction:(UIButton *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self configUI];
}

- (void)configUI {
    [self.filmthumbView sd_setImageWithURL:[LCFunction XWX_URLImg:self.video.filmthumb]];
    self.filmtitleLb.text = self.video.filmtitle;
    self.sourcecharLb.text = self.video.sourcechar;
    self.shareNumLb.text = kFORMAT(@"推广人数：%@",self.video.promotersnum);
    self.prodateLb.text = kFORMAT(@"上线时间：%@",self.video.prodate);
    
    [self.qrcodeView sd_setImageWithURL:[LCFunction XWX_URLImg:self.video.promotersqrc]];
    
    self.filmdescLb.text = self.video.popularize.length ? self.video.popularize : self.video.filmdescrption.length ? self.video.filmdescrption : @"推广素材请前往星图任务详情页下滑获取。";
}


- (IBAction)saveImgAction:(UIButton *)sender {
    UIImage * img = [UIImage imageCaptureWithView:self.qrcodeBg];
    
    [[TZImageManager manager] savePhotoWithImage:img completion:^(PHAsset *asset, NSError *error) {
        if (!error && asset) {
            [self showSuccessText:@"图片已保存"];
        }
    }];
}

- (IBAction)linkShareAction:(UIButton *)sender {
    UIPasteboard *pab = [UIPasteboard generalPasteboard];
    [pab setString:self.video.promotersurl];
    if(pab == nil) {
        [self showErrorText:@"复制失败"];
    }else{
        [self showSuccessText:@"复制成功"];
    }
}

- (IBAction)pushTuDouYingAction:(UIButton *)sender {
    if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"snssdk1128://"]]) {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"snssdk1128://"] options:@{} completionHandler:^(BOOL success) {
        }];
    } else {
        [self showErrorText:@"没有安装抖音"];
    }
}

@end
